package com.cyy.demo.api;

import com.cyy.demo.entity.SystemLog;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

@Component
public class HandleLimit {

    @Pointcut("@annotation(com.cyy.demo.api.Limit)")
    public void logAspect(){

    }

    @Before("logAspect()")
    public void doBefore(JoinPoint joinPoint, Throwable e) throws Throwable{
        System.out.println("Before");
    }

    @AfterThrowing("logAspect()")
    public void doAfterThrowing(JoinPoint joinPoint, Throwable e) throws Throwable{
        System.out.println("AfterThrowing");
        e.printStackTrace();
    }

    @After("logAspect()")
    public void doAfter(JoinPoint joinPoint) throws Throwable{
        System.out.println("After");
    }

    @AfterReturning("logAspect()")
    public void doAfterReturning(JoinPoint joinPoint) throws Throwable{
        System.out.println("AfterReturning");
    }

    @Around("logAspect()")
    public void doAround(ProceedingJoinPoint joinPoint) throws Throwable{
        System.out.println("AfterReturning");
    }
}
